package ui.textfield 
{
	import flash.events.TextEvent;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
	
	/**
	 * A textfield to be used by the game
	 * @author Roy
	 */
	public class GCTextField extends TextField 
	{
		public static const TEXT_TYPE_TITLE:uint = 0;
		public static const TEXT_TYPE_DESC:uint = 1;
		public static const TEXT_TYPE_INFORMATION:uint = 2;
		public static const TEXT_TYPE_LEVEL:uint = 3;
		public static const TEXT_TYPE_QUEST:uint = 4;
		public static const TEXT_TYPE_RIGHT:uint = 5;
		public static const TEXT_TYPE_LEFT:uint = 6;
		public static const TEXT_TYPE_DEFAULT:uint = 9999;
		
		public static var REGULAR_FORMAT:TextFormat;
		public static var TITLE_FORMAT:TextFormat;
		public static var INFORMATION_FORMAT:TextFormat;
		public static var LEVEL_FORMAT:TextFormat;
		public static var QUEST_FORMAT:TextFormat;
		public static var RIGHT_FORMAT:TextFormat;
		public static var LEFT_FORMAT:TextFormat;
		
		public function GCTextField() 
		{
			super();
			this.selectable = false;
			this.wordWrap = true;
			
			setStyle(TEXT_TYPE_DEFAULT);
		}
		
		public function setXY(x:int, y:int):void
		{
			this.x = x;
			this.y = y;
		}
		
		public function setDimensions(width:int, height:int):void
		{
			this.width = width;
			this.height = height;
		}
		
		public function setStyle(type:uint):void
		{
			switch(type)
			{
				case TEXT_TYPE_TITLE:
					break;
				case TEXT_TYPE_DESC:
					this.defaultTextFormat = REGULAR_FORMAT;
					break;
				case TEXT_TYPE_LEVEL:
					this.defaultTextFormat = LEVEL_FORMAT;
					break;
				case TEXT_TYPE_INFORMATION:
					this.defaultTextFormat = INFORMATION_FORMAT;
					break;
				case TEXT_TYPE_QUEST:
					this.defaultTextFormat = QUEST_FORMAT;
					break;
				case TEXT_TYPE_RIGHT:
					this.defaultTextFormat = RIGHT_FORMAT;
					break;
				case TEXT_TYPE_LEFT:
					this.defaultTextFormat = LEFT_FORMAT;
					break;
				default:
					this.defaultTextFormat = REGULAR_FORMAT;
			}
			
			
		}
		
		public static function initTextFormats():void
		{
			REGULAR_FORMAT = new TextFormat();
			REGULAR_FORMAT.font = "Arial";
			REGULAR_FORMAT.size = 12;
			REGULAR_FORMAT.align = TextFormatAlign.CENTER;
			
			TITLE_FORMAT = new TextFormat();
			
			INFORMATION_FORMAT = new TextFormat();
			INFORMATION_FORMAT.font = "Arial";
			INFORMATION_FORMAT.size = 14;
			
			LEVEL_FORMAT = new TextFormat();
			LEVEL_FORMAT.font = "Arial";
			LEVEL_FORMAT.size = 16;
			LEVEL_FORMAT.align = TextFormatAlign.CENTER;
			
			QUEST_FORMAT = new TextFormat();
			QUEST_FORMAT.font = "Arial";
			QUEST_FORMAT.size = 10;
			QUEST_FORMAT.align = TextFormatAlign.LEFT;
			QUEST_FORMAT.bold = true;
			
			RIGHT_FORMAT = new TextFormat();
			RIGHT_FORMAT.font = "Arial";
			RIGHT_FORMAT.size = 12;
			RIGHT_FORMAT.align = TextFormatAlign.RIGHT;
			
			LEFT_FORMAT = new TextFormat();
			LEFT_FORMAT.font = "Arial";
			LEFT_FORMAT.size = 12;
			LEFT_FORMAT.align = TextFormatAlign.LEFT;
		}
	}

}